﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using COM.OA.Entity;
using COM.OA.BLL;
using System.Collections.Generic;

public partial class lb_shenpi_updateshenpi : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int id =Int32.Parse( this.Request.Params["id"]);
        examine ex = examineBLL.Select(id);
        users u = usersBLL.Select(ex.ex_u_id,true,false);
        this.txbsy.Text = ex.ex_applycontent;
        this.FreeTextBox1.Text = ex.ex_define;
        this.txbbz.Text = ex.ex_remark;
        this.txbname.Text = u.employee.em_name;
    }
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        //验证
        this.check();
        //申请人
        string name = this.txbname.Text;
        string where = "u_em_id =(select em_id from employee where em_name ='" + name + "')";

        IList<users> elist = usersBLL.Select(where);
        users u = elist[0];

        examine ex = new examine();
        //事由
        ex.ex_applycontent = this.txbsy.Text;
        //备注
        ex.ex_remark = this.txbbz.Text;
        //说明
        ex.ex_define = this.FreeTextBox1.Text;
        //申请时间
        ex.ex_applytime = DateTime.Now.ToLocalTime();
        ex.ex_examinetiem = DateTime.Now.ToLocalTime();
        //状态
        ex.ex_state = 0;
        //申请人ID
        ex.ex_u_id = u.u_id;
        //部门
        ex.ex_dept_id = u.u_dept_id;
        //把审批的实体放入会话
        Session.Add("examines", ex);
        this.Response.Redirect("updatepost.aspx");

    }
    protected void btnReset_Click(object sender, EventArgs e)
    {
        this.txbsy.Text = "";
        this.txbbz.Text = "";
        this.FreeTextBox1.Text = "";

    }
    private void check()
    {
        if (this.txbsy.Text == "")
        {
            this.Response.Write(string.Format(GetRedirect.WINALERT, "请填写事由"));
            this.txbsy.Focus();
            return;
        }
        if (this.FreeTextBox1.Text == "")
        {
            this.Response.Write(string.Format(GetRedirect.WINALERT, "请填写审批说明"));
            this.FreeTextBox1.Focus = true;
            return;
        }
    }
}
